package com.mouse.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mouse.entity.CategoryAllele;
import com.mouse.entity.CategoryAllele;
import com.mouse.mapper.CategoryAlleleMapper;
import com.mouse.service.CategoryAlleleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mouse.util.StringUtil;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author godson
 * @since 2022-08-07
 */
@Service
public class CategoryAlleleServiceImpl extends ServiceImpl<CategoryAlleleMapper, CategoryAllele> implements CategoryAlleleService {

    /***
     * 查询：根据一个字段信息查询表格信息，支持字段值类型为ID和String
     * @param page 分页设置
     * @param key 字段名
     * @param value 字段值
     * @return 查询结果
     */
    @Override
    public IPage<CategoryAllele> getInfoByMap(IPage<CategoryAllele> page, String key, String value){
        long id;
        QueryWrapper<CategoryAllele> wrapper = new QueryWrapper<>();
        if(StringUtil.isInteger(value)){
            id = Long.parseLong(value);
            wrapper.eq(key,id);
        } else {
            wrapper.eq(key,value);
        }
        return baseMapper.selectPage(page,wrapper);
    }
}
